/*
 * Ganesa Copyright (C) 2008 Wim Crols <twimpiex@gnx.be>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 3
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

package be.gnx.ganesa.application.ui;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;

import be.gnx.ganesa.application.controller.Exit;
import be.gnx.ganesa.application.controller.Import;
import be.gnx.ganesa.application.controller.NewProject;

public class MenuBar {

  private Menu menuBar;

  public MenuBar(Ganesa ganesa, Shell shell) {
    createMenuBar(ganesa, shell);
  }

  public void createMenuBar(Ganesa ganesa, Shell shell) {
    menuBar = new Menu(shell, SWT.BAR);
    MenuItem fileMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
    fileMenuHeader.setText("File");
    Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
    fileMenuHeader.setMenu(fileMenu);
    MenuItem fileNewMenuItem = new MenuItem(fileMenu, SWT.PUSH);
    fileNewMenuItem.setText("New");
    MenuItem fileNewLayerMenuItem = new MenuItem(fileMenu, SWT.PUSH);
    fileNewLayerMenuItem.setText("New layer");
    MenuItem fileOpenMenuItem = new MenuItem(fileMenu, SWT.PUSH);
    fileOpenMenuItem.setText("Open ...");
    new MenuItem(fileMenu, SWT.SEPARATOR);
    MenuItem fileCloseMenuItem = new MenuItem(fileMenu, SWT.PUSH);
    fileCloseMenuItem.setText("Close");
    new MenuItem(fileMenu, SWT.SEPARATOR);
    MenuItem fileSaveMenuItem = new MenuItem(fileMenu, SWT.PUSH);
    fileSaveMenuItem.setText("Save");
    MenuItem fileSaveAsMenuItem = new MenuItem(fileMenu, SWT.PUSH);
    fileSaveAsMenuItem.setText("Save as ...");
    new MenuItem(fileMenu, SWT.SEPARATOR);
    MenuItem fileImportMenuItem = new MenuItem(fileMenu, SWT.PUSH);
    fileImportMenuItem.setText("Import ...");
    MenuItem fileExportMenuItem = new MenuItem(fileMenu, SWT.PUSH);
    fileExportMenuItem.setText("Export ...");
    new MenuItem(fileMenu, SWT.SEPARATOR);
    MenuItem filePropertiesMenuItem = new MenuItem(fileMenu, SWT.PUSH);
    filePropertiesMenuItem.setText("Properties");
    new MenuItem(fileMenu, SWT.SEPARATOR);
    // here i should add recently opened files;
    new MenuItem(fileMenu, SWT.SEPARATOR);
    MenuItem fileExitMenuItem = new MenuItem(fileMenu, SWT.PUSH);
    fileExitMenuItem.setText("Exit");

    MenuItem helpMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
    helpMenuHeader.setText("Help");
    Menu helpMenu = new Menu(shell, SWT.DROP_DOWN);
    helpMenuHeader.setMenu(helpMenu);
    MenuItem helpAboutGanesaMenuItem = new MenuItem(helpMenu, SWT.PUSH);
    helpAboutGanesaMenuItem.setText("About Ganesa");

    shell.setMenuBar(menuBar);

    fileNewMenuItem.addSelectionListener(new NewProject(ganesa));
    fileImportMenuItem.addSelectionListener(new Import(ganesa));
    fileExitMenuItem.addSelectionListener(new Exit(ganesa));
  }

}
